﻿

using System;
using Demo.Infrastructure.IO;

namespace Demo.Infrastructure.Log
{
    /// <summary>
    /// 文本日志 配置文件《LogPath》节点支持，默认值为程序当前目录
    /// </summary>
    public class LogText : ILog
    {
        /// <summary>
        /// 日志文件默认全路径
        /// </summary>
        public static readonly string TempPath = AppDomain.CurrentDomain.BaseDirectory + @"log.txt";

        /// <summary>
        /// 日志文件全路径
        /// </summary>
        public static readonly string LogPath = AppSettingUtils.AppSettings<string>("LogPath",TempPath);

        /// <summary>
        /// 写文本日志
        /// </summary>
        /// <param name="message">文本信息</param>
        [STAThread]
        public void Log(string message)
        {
            //Utils.Log(message);
            FileUtils.GetInstance(LogPath).AppendText(message);
        }

        /// <summary>
        /// 写文本日志
        /// </summary>
        /// <param name="ex">异常信息</param>
        [STAThread]
        public void Log(Exception ex)
        {
            //Utils.Log(ex);
            FileUtils.GetInstance(LogPath).AppendText(ex.ToString());
        }
    }

}
